cmake_minimum_required(VERSION 3.22)
project(Sofa.Component.Topology.Container.Dynamic LANGUAGES CXX)

set(SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR "src/sofa/component/topology/container/dynamic")

set(HEADER_FILES
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/config.h.in
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/init.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/fwd.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/CommonAlgorithms.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/DynamicSparseGridGeometryAlgorithms.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/DynamicSparseGridGeometryAlgorithms.inl
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/DynamicSparseGridTopologyContainer.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/DynamicSparseGridTopologyModifier.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/EdgeSetGeometryAlgorithms.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/EdgeSetGeometryAlgorithms.inl
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/EdgeSetTopologyContainer.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/EdgeSetTopologyModifier.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/HexahedronSetGeometryAlgorithms.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/HexahedronSetGeometryAlgorithms.inl
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/HexahedronSetTopologyContainer.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/HexahedronSetTopologyModifier.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/MultilevelHexahedronSetTopologyContainer.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/NumericalIntegrationDescriptor.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/NumericalIntegrationDescriptor.inl
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/PointModifiers.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/PointSetGeometryAlgorithms.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/PointSetGeometryAlgorithms.inl
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/PointSetTopologyContainer.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/PointSetTopologyModifier.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/QuadSetGeometryAlgorithms.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/QuadSetGeometryAlgorithms.inl
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/QuadSetTopologyContainer.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/QuadSetTopologyModifier.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/TetrahedronSetGeometryAlgorithms.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/TetrahedronSetGeometryAlgorithms.inl
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/TetrahedronSetTopologyContainer.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/TetrahedronSetTopologyModifier.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/TriangleSetGeometryAlgorithms.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/TriangleSetGeometryAlgorithms.inl
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/TriangleSetTopologyContainer.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/TriangleSetTopologyModifier.h
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/TriangleSubdividers.h
)

set(SOURCE_FILES
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/init.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/EdgeSetGeometryAlgorithms.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/EdgeSetTopologyContainer.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/EdgeSetTopologyModifier.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/HexahedronSetGeometryAlgorithms.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/HexahedronSetTopologyContainer.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/HexahedronSetTopologyModifier.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/MultilevelHexahedronSetTopologyContainer.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/NumericalIntegrationDescriptor.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/PointSetGeometryAlgorithms.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/PointSetTopologyContainer.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/PointSetTopologyModifier.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/QuadSetGeometryAlgorithms.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/QuadSetTopologyContainer.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/QuadSetTopologyModifier.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/TetrahedronSetGeometryAlgorithms.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/TetrahedronSetTopologyContainer.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/TetrahedronSetTopologyModifier.cpp    
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/TriangleSetGeometryAlgorithms.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/TriangleSetTopologyContainer.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/TriangleSetTopologyModifier.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/TriangleSubdividers.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/DynamicSparseGridGeometryAlgorithms.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/DynamicSparseGridTopologyContainer.cpp
    ${SOFACOMPONENTTOPOLOGYCONTAINERDYNAMIC_SOURCE_DIR}/DynamicSparseGridTopologyModifier.cpp
)

sofa_find_package(Sofa.Simulation.Core REQUIRED)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Simulation.Core)

sofa_create_package_with_targets(
    PACKAGE_NAME ${PROJECT_NAME}
    PACKAGE_VERSION ${Sofa_VERSION}
    TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
    INCLUDE_SOURCE_DIR "src"
    INCLUDE_INSTALL_DIR "${PROJECT_NAME}"
)

# Tests
# If SOFA_BUILD_TESTS exists and is OFF, then these tests will be auto-disabled
cmake_dependent_option(SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_BUILD_TESTS "Compile the automatic tests" ON "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF)
if(SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_BUILD_TESTS)
    enable_testing()
    add_subdirectory(tests)
endif()
